package com.west_traveler.find_page_fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.west_traveler.entity.entity_find_second_hot_recommend.SecondHotRecommendDetail;
import com.west_traveler.recyclerview_adapter.SecondDetailRecyclerViewAdapter;
import com.west_traveler.ximalayafm.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class SecondDetailFragment extends Fragment {

    private SecondHotRecommendDetail.DataBean dataDetail;

    public static SecondDetailFragment getInstance(Object obj) {
        SecondDetailFragment fragment = new SecondDetailFragment();
        Bundle bundle = new Bundle();
        if (obj instanceof SecondHotRecommendDetail.DataBean) {
            bundle.putParcelable("dataDetail", ((SecondHotRecommendDetail.DataBean) obj));
        }
        fragment.setArguments(bundle);
        return fragment;
    }

    public SecondDetailFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        Bundle bundle = getArguments();
        dataDetail = bundle.getParcelable("dataDetail");
        return inflater.inflate(R.layout.fragment_second_detail, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview_detail);

        SecondDetailRecyclerViewAdapter adapter = new SecondDetailRecyclerViewAdapter(getActivity(),dataDetail);
        recyclerView.setAdapter(adapter);

    }
}
